﻿namespace HRM.CORE
{
    using DevExpress.Utils;
    using DevExpress.XtraEditors;
    using DevExpress.XtraNavBar;
    using DevExpress.XtraNavBar.ViewInfo;
    using HRM.CORE;
    using HRM.CORE.Workdesk;
    
    using System; using Extra.ERP;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Windows.Forms; using Common;
    using APP.HELPER.Utils.Language;

    public class xfmTotalUp : XtraForm
    {
        private NavBarItem bbiChart;
        private NavBarItem bbiFurlough;
        private NavBarItem bbiInsuranceByMonth;
        private NavBarItem bbiSalaryByDepartment;
        private NavBarItem bbiSalaryByEmployee;
        private NavBarItem bbiTotalYear;
        private IContainer components = null;
        private GroupControl gcControl;
        private DevExpress.Utils.ImageCollection imgClassic;
        private DevExpress.Utils.ImageCollection imgMetro;
        private NavBarControl navBarControl1;
        private NavBarGroup navEmployee;
        private NavBarGroup navSalary;
        private HRM.CORE.Workdesk.xucChart xucChart;
        private HRM.CORE.xucInsuranceByMonth xucInsuranceByMonth;
        private HRM.CORE.xucSalaryByDepartment xucSalaryByDepartment;
        private HRM.CORE.xucSalaryByEmployee xucSalaryByEmployee;
        private HRM.CORE.xucTimekeeperBySymbol xucTimekeeperBySymbol;
        private HRM.CORE.xucTimeKeeperFurlough xucTimeKeeperFurlough;
        private HRM.CORE.xucTimekeeperTotalYear xucTimekeeperTotalYear;

        public xfmTotalUp()
        {
            this.InitializeComponent();
            this.InitMultiLanguages();
            base.Load += new EventHandler(this.xfmTotalUp_Load);
        }

        private void bbiChart_LinkClicked(object sender, NavBarLinkEventArgs e)
        {
            this.Execute("xucChart", "");
        }

        private void bbiFurlough_LinkClicked(object sender, NavBarLinkEventArgs e)
        {
            this.Execute("xucTimeKeeperFurlough", "");
        }

        private void bbiInsuranceByMonth_LinkClicked(object sender, NavBarLinkEventArgs e)
        {
            this.Execute("xucInsuranceByMonth", "");
        }

        private void bbiSalaryByDepartment_LinkClicked(object sender, NavBarLinkEventArgs e)
        {
            this.Execute("xucSalaryByDepartment", "");
        }

        private void bbiSalaryByEmployee_LinkClicked(object sender, NavBarLinkEventArgs e)
        {
            this.Execute("xucSalaryByEmployee", "");
        }

        private void bbiTotalYear_LinkClicked(object sender, NavBarLinkEventArgs e)
        {
            this.Execute("xucTimekeeperTotalYear", "");
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void Execute(string id, string @ref)
        {
            switch (id)
            {
                case "xucSalaryByEmployee":
                    SYS_LOG.Insert(this.bbiSalaryByEmployee.Caption, "Xem");
                    this.gcControl.Text = this.bbiSalaryByEmployee.Caption;
                    if (this.xucSalaryByEmployee != null)
                    {
                        this.xucSalaryByEmployee.BringToFront();
                        break;
                    }
                    this.xucSalaryByEmployee = new HRM.CORE.xucSalaryByEmployee();
                    this.xucSalaryByEmployee.Dock = DockStyle.Fill;
                    this.gcControl.Controls.Add(this.xucSalaryByEmployee);
                    this.xucSalaryByEmployee.BringToFront();
                    break;

                case "xucSalaryByDepartment":
                    SYS_LOG.Insert(this.bbiSalaryByDepartment.Caption, "Xem");
                    this.gcControl.Text = this.bbiSalaryByDepartment.Caption;
                    if (this.xucSalaryByDepartment != null)
                    {
                        this.xucSalaryByDepartment.BringToFront();
                        break;
                    }
                    this.xucSalaryByDepartment = new HRM.CORE.xucSalaryByDepartment();
                    this.xucSalaryByDepartment.Dock = DockStyle.Fill;
                    this.gcControl.Controls.Add(this.xucSalaryByDepartment);
                    this.xucSalaryByDepartment.BringToFront();
                    break;

                case "xucInsuranceByMonth":
                    SYS_LOG.Insert(this.bbiInsuranceByMonth.Caption, "Xem");
                    this.gcControl.Text = this.bbiInsuranceByMonth.Caption;
                    if (this.xucInsuranceByMonth != null)
                    {
                        this.xucInsuranceByMonth.BringToFront();
                        break;
                    }
                    this.xucInsuranceByMonth = new HRM.CORE.xucInsuranceByMonth();
                    this.xucInsuranceByMonth.Dock = DockStyle.Fill;
                    this.gcControl.Controls.Add(this.xucInsuranceByMonth);
                    this.xucInsuranceByMonth.BringToFront();
                    break;

                case "xucTimeKeeperFurlough":
                    SYS_LOG.Insert(this.bbiFurlough.Caption, "Xem");
                    this.gcControl.Text = this.bbiFurlough.Caption;
                    if (this.xucTimeKeeperFurlough != null)
                    {
                        this.xucTimeKeeperFurlough.BringToFront();
                        break;
                    }
                    this.xucTimeKeeperFurlough = new HRM.CORE.xucTimeKeeperFurlough();
                    this.xucTimeKeeperFurlough.Dock = DockStyle.Fill;
                    this.gcControl.Controls.Add(this.xucTimeKeeperFurlough);
                    this.xucTimeKeeperFurlough.BringToFront();
                    break;

                case "xucTimekeeperBySymbol":
                    SYS_LOG.Insert(this.bbiTotalYear.Caption, "Xem");
                    this.gcControl.Text = this.bbiTotalYear.Caption;
                    if (this.xucTimekeeperBySymbol != null)
                    {
                        this.xucTimekeeperBySymbol.BringToFront();
                        break;
                    }
                    this.xucTimekeeperBySymbol = new HRM.CORE.xucTimekeeperBySymbol();
                    this.xucTimekeeperBySymbol.Dock = DockStyle.Fill;
                    this.gcControl.Controls.Add(this.xucTimekeeperBySymbol);
                    this.xucTimekeeperBySymbol.BringToFront();
                    break;

                case "xucTimekeeperTotalYear":
                    SYS_LOG.Insert(this.bbiTotalYear.Caption, "Xem");
                    this.gcControl.Text = this.bbiTotalYear.Caption;
                    if (this.xucTimekeeperTotalYear != null)
                    {
                        this.xucTimekeeperTotalYear.BringToFront();
                        break;
                    }
                    this.xucTimekeeperTotalYear = new HRM.CORE.xucTimekeeperTotalYear();
                    this.xucTimekeeperTotalYear.Dock = DockStyle.Fill;
                    this.gcControl.Controls.Add(this.xucTimekeeperTotalYear);
                    this.xucTimekeeperTotalYear.BringToFront();
                    break;

                case "xucChart":
                    SYS_LOG.Insert(this.bbiChart.Caption, "Xem");
                    this.gcControl.Text = this.bbiChart.Caption;
                    if (this.xucChart != null)
                    {
                        this.xucChart.BringToFront();
                        break;
                    }
                    this.xucChart = new HRM.CORE.Workdesk.xucChart();
                    this.xucChart.SetNoBorder();
                    this.xucChart.LoadData();
                    this.xucChart.Dock = DockStyle.Fill;
                    this.gcControl.Controls.Add(this.xucChart);
                    this.xucChart.BringToFront();
                    break;
            }
        }

        private void InitializeComponent()
        {
            this.components = new Container();
            ComponentResourceManager manager = new ComponentResourceManager(typeof(xfmTotalUp));
            this.navBarControl1 = new NavBarControl();
            this.navEmployee = new NavBarGroup();
            this.bbiChart = new NavBarItem();
            this.bbiTotalYear = new NavBarItem();
            this.bbiFurlough = new NavBarItem();
            this.navSalary = new NavBarGroup();
            this.bbiSalaryByEmployee = new NavBarItem();
            this.bbiSalaryByDepartment = new NavBarItem();
            this.bbiInsuranceByMonth = new NavBarItem();
            this.imgMetro = new DevExpress.Utils.ImageCollection(this.components);
            this.imgClassic = new DevExpress.Utils.ImageCollection(this.components);
            this.gcControl = new GroupControl();
            this.navBarControl1.BeginInit();
            this.imgMetro.BeginInit();
            this.imgClassic.BeginInit();
            this.gcControl.BeginInit();
            base.SuspendLayout();
            this.navBarControl1.ActiveGroup = this.navEmployee;
            this.navBarControl1.ContentButtonHint = null;
            this.navBarControl1.Dock = DockStyle.Left;
            this.navBarControl1.Groups.AddRange(new NavBarGroup[] { this.navEmployee, this.navSalary });
            this.navBarControl1.Items.AddRange(new NavBarItem[] { this.bbiSalaryByDepartment, this.bbiSalaryByEmployee, this.bbiFurlough, this.bbiChart, this.bbiInsuranceByMonth, this.bbiTotalYear });
            this.navBarControl1.LargeImages = this.imgMetro;
            this.navBarControl1.Location = new Point(0, 0);
            this.navBarControl1.Name = "navBarControl1";
            this.navBarControl1.OptionsNavPane.ExpandedWidth = 0xda;
            this.navBarControl1.Size = new Size(0xa4, 0x1ed);
            this.navBarControl1.SmallImages = this.imgClassic;
            this.navBarControl1.TabIndex = 3;
            this.navBarControl1.Text = "navBarControl1";
            this.navBarControl1.View = new SkinNavigationPaneViewInfoRegistrator();
            this.navEmployee.Caption = "T\x00ecnh H\x00ecnh Nh\x00e2n Sự";
            this.navEmployee.Expanded = true;
            this.navEmployee.ItemLinks.AddRange(new NavBarItemLink[] { new NavBarItemLink(this.bbiChart), new NavBarItemLink(this.bbiTotalYear), new NavBarItemLink(this.bbiFurlough) });
            this.navEmployee.Name = "navEmployee";
            this.navEmployee.SmallImageIndex = 1;
            this.bbiChart.Appearance.Options.UseTextOptions = true;
            this.bbiChart.Appearance.TextOptions.WordWrap = WordWrap.Wrap;
            this.bbiChart.Caption = "Biểu đồ thống k\x00ea t\x00ecnh h\x00ecnh nh\x00e2n sự";
            this.bbiChart.Name = "bbiChart";
            this.bbiChart.SmallImageIndex = 1;
            this.bbiChart.LinkClicked += new NavBarLinkEventHandler(this.bbiChart_LinkClicked);
            this.bbiTotalYear.Appearance.Options.UseTextOptions = true;
            this.bbiTotalYear.Appearance.TextOptions.WordWrap = WordWrap.Wrap;
            this.bbiTotalYear.Caption = "Tổng hợp dữ liệu chấm c\x00f4ng theo năm";
            this.bbiTotalYear.Name = "bbiTotalYear";
            this.bbiTotalYear.SmallImageIndex = 1;
            this.bbiTotalYear.LinkClicked += new NavBarLinkEventHandler(this.bbiTotalYear_LinkClicked);
            this.bbiFurlough.Appearance.Options.UseTextOptions = true;
            this.bbiFurlough.Appearance.TextOptions.WordWrap = WordWrap.Wrap;
            this.bbiFurlough.Caption = "Thống k\x00ea ng\x00e0y nghỉ ph\x00e9p năm";
            this.bbiFurlough.Name = "bbiFurlough";
            this.bbiFurlough.SmallImageIndex = 1;
            this.bbiFurlough.LinkClicked += new NavBarLinkEventHandler(this.bbiFurlough_LinkClicked);
            this.navSalary.Caption = "Thống K\x00ea Lương";
            this.navSalary.ItemLinks.AddRange(new NavBarItemLink[] { new NavBarItemLink(this.bbiSalaryByEmployee), new NavBarItemLink(this.bbiSalaryByDepartment), new NavBarItemLink(this.bbiInsuranceByMonth) });
            this.navSalary.Name = "navSalary";
            this.navSalary.SmallImageIndex = 0;
            this.bbiSalaryByEmployee.Appearance.Options.UseTextOptions = true;
            this.bbiSalaryByEmployee.Appearance.TextOptions.WordWrap = WordWrap.Wrap;
            this.bbiSalaryByEmployee.Caption = "Thống k\x00ea lương theo nh\x00e2n vi\x00ean (theo từng năm)";
            this.bbiSalaryByEmployee.Name = "bbiSalaryByEmployee";
            this.bbiSalaryByEmployee.SmallImageIndex = 0;
            this.bbiSalaryByEmployee.LinkClicked += new NavBarLinkEventHandler(this.bbiSalaryByEmployee_LinkClicked);
            this.bbiSalaryByDepartment.Appearance.Options.UseTextOptions = true;
            this.bbiSalaryByDepartment.Appearance.TextOptions.WordWrap = WordWrap.Wrap;
            this.bbiSalaryByDepartment.Caption = "Thống k\x00ea lương theo ph\x00f2ng ban (theo từng năm)";
            this.bbiSalaryByDepartment.Name = "bbiSalaryByDepartment";
            this.bbiSalaryByDepartment.SmallImageIndex = 0;
            this.bbiSalaryByDepartment.LinkClicked += new NavBarLinkEventHandler(this.bbiSalaryByDepartment_LinkClicked);
            this.bbiInsuranceByMonth.Appearance.Options.UseTextOptions = true;
            this.bbiInsuranceByMonth.Appearance.TextOptions.WordWrap = WordWrap.Wrap;
            this.bbiInsuranceByMonth.Caption = "Thống k\x00ea danh s\x00e1ch tham gia BHXH theo ph\x00f2ng ban (theo từng th\x00e1ng)";
            this.bbiInsuranceByMonth.Name = "bbiInsuranceByMonth";
            this.bbiInsuranceByMonth.SmallImageIndex = 0;
            this.bbiInsuranceByMonth.LinkClicked += new NavBarLinkEventHandler(this.bbiInsuranceByMonth_LinkClicked);
            this.imgMetro.ImageSize = new Size(0x20, 0x20);
            this.imgMetro.ImageStream = (ImageCollectionStreamer) manager.GetObject("imgMetro.ImageStream");
            this.imgMetro.Images.SetKeyName(0, "bbiSalary.png");
            this.imgMetro.Images.SetKeyName(1, "bbiTimekeeping.png");
            this.imgClassic.ImageSize = new Size(0x20, 0x20);
            this.imgClassic.ImageStream = (ImageCollectionStreamer) manager.GetObject("imgClassic.ImageStream");
            this.imgClassic.Images.SetKeyName(0, "bbiSalary");
            this.imgClassic.Images.SetKeyName(1, "bbiTimekeeping.png");
            this.gcControl.AppearanceCaption.Font = new Font("Tahoma", 8.25f, FontStyle.Bold);
            this.gcControl.AppearanceCaption.Options.UseFont = true;
            this.gcControl.Dock = DockStyle.Fill;
            this.gcControl.Location = new Point(0xa4, 0);
            this.gcControl.Name = "gcControl";
            this.gcControl.Size = new Size(0x261, 0x1ed);
            this.gcControl.TabIndex = 4;
            this.gcControl.Text = "groupControl1";
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.ClientSize = new Size(0x305, 0x1ed);
            base.Controls.Add(this.gcControl);
            base.Controls.Add(this.navBarControl1);
            base.Name = "xfmTotalUp";
            this.Text = "Thống K\x00ea Số Liệu";
            this.navBarControl1.EndInit();
            this.imgMetro.EndInit();
            this.imgClassic.EndInit();
            this.gcControl.EndInit();
            base.ResumeLayout(false);
        }

        private void InitMultiLanguages()
        {
            this.Text = MultiLanguages.GetString("tbl_Statistics", "Statistics", "Thống K\x00ea Số Liệu");
            this.navEmployee.Caption = MultiLanguages.GetString("tbl_Statistics", "StatisticalPersonnel", "T\x00ecnh H\x00ecnh Nh\x00e2n Sự");
            this.navSalary.Caption = MultiLanguages.GetString("tbl_Statistics", "WageStatistics", "Thống K\x00ea Lương");
            this.bbiChart.Caption = MultiLanguages.GetString("tbl_Statistics", "ChartStatisticsPersonnel", "Biều đồ thống k\x00ea t\x00ecnh h\x00ecnh nh\x00e2n sự");
            this.bbiFurlough.Caption = MultiLanguages.GetString("tbl_Statistics", "StatisticOnAnnualLeave", "Thống k\x00ea ng\x00e0y nghỉ ph\x00e9p năm");
            this.bbiSalaryByEmployee.Caption = MultiLanguages.GetString("tbl_Statistics", "StatisticsForEachEmployee", "Th\x00f4ng k\x00ea lương theo từng nh\x00e2n vi\x00ean (theo năm)");
            this.bbiSalaryByDepartment.Caption = MultiLanguages.GetString("tbl_Statistics", "StatisticsForDepartments", "Thống k\x00ea lương theo ph\x00f2ng ban (theo năm)");
        }

        private static string LoadStyle()
        {
            DataSet set = new DataSet();
            set.ReadXml(Application.StartupPath + @"\Layout\Theme.xml");
            return set.Tables[0].Rows[0][1].ToString();
        }

        public void SetStyle(string Style)
        {
            if (Style == "Classic")
            {
                this.navBarControl1.SmallImages = this.imgClassic;
            }
            else
            {
                this.navBarControl1.SmallImages = this.imgMetro;
            }
        }

        private void xfmTotalUp_Load(object sender, EventArgs e)
        {
            this.SetStyle(LoadStyle());
            this.Execute("xucChart", "");
        }
    }
}

